package edu.zut.cs.javaee.dream.conf;

import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class WebConfig implements WebMvcConfigurer {
    /**
     * @param Registry 1.访问路径
     *                 2.请求来源
     *                 3.方法
     *                 4.允许携带
     *                 5.最大时间
     */
    @Override
    public void addCorsMappings(CorsRegistry Registry) {
        Registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "POST", "PUT", "OPTIONS", "DELETE")
                .allowCredentials(true)
                .allowedHeaders("Access-Control-Allow-Origin")
                .maxAge(3600);
    }

}
